package test1230pm;

public class Test02 {
    public static void main(String[] args) {
        // (2)设计一个圆形类
        // 属性：半径、PI
        // 功能：周长、面积
        // 要求：分别创建3个对象、求周长、求面积
        Yuan yuan1 = new Yuan(4);
        Yuan yuan2 = new Yuan(5);
        Yuan yuan3 = new Yuan(6);
        System.out.println("yuan1的面积：" + yuan1.getArea() + " 周长：" + yuan1.getCircumference());
        System.out.println("yuan2的面积：" + yuan2.getArea() + " 周长：" + yuan2.getCircumference());
        System.out.println("yuan3的面积：" + yuan3.getArea() + " 周长：" + yuan3.getCircumference());

    }
    public static class Yuan {
        double radius;
        private static final double PI = 3.14;

        public  double getArea() {
            return PI * radius * radius;
        }

        public double getCircumference() {
            return 2 * PI * radius;
        }

        public double getRadius() {
            return radius;
        }

        public void setRadius(double radius) {
            this.radius = radius;
        }

        public Yuan(double radius) {
            this.radius = radius;
        }

        public Yuan() {
        }

        @Override
        public String toString() {
            return "Yuan{" +
                    "radius=" + radius +
                    '}';
        }
    }
}
